from matplotlib import image
import os

xpath = r'../../../../../large_data/pic'
xlist = os.listdir(xpath)
x_pic_data = []
for x in xlist:
    p = os.path.join(xpath, x)
    if not os.path.exists(p):
        continue
    if os.path.isdir(p):
        continue
    if '.nomedia' == x:
        continue
    print(x)
    pic = image.imread(p)
    print(pic.dtype, pic.shape)
    x_pic_data.append(pic)

if '__main__' == __name__:
    import matplotlib.pyplot as plt
    plt.figure(figsize=[16, 8])
    spr = 2  # subplot row
    spc = 4  # subplot column
    spn = 0
    for pic in x_pic_data:
        spn += 1
        if spn > spr * spc:
            break
        plt.subplot(spr, spc, spn)
        plt.title(f'#{spn}')
        plt.imshow(pic)
